package com.lt.lumentracks.context;

public class BaseContext {

    public static ThreadLocal<Integer> threadLocal = new ThreadLocal<>();

    public static void setCurrentId(Integer id) {
        System.out.println("用户id：" + id + "存入线程：" + Thread.currentThread().getName());
        threadLocal.set(id);
    }

    public static Integer getCurrentId() {
        return threadLocal.get();
    }

    public static void removeCurrentId() {
        threadLocal.remove(); // 删除此线程局部变量的当前线程值
        System.out.println("线程：" + Thread.currentThread().getName() + "中的用户id已删除");
    }

}
